package com.yoyo.itravel.dao;

import com.yoyo.itravel.bean.SightImg;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 * @Description 景点图片操作持久层接口
 * @Author HZX
 * @Version 1.0
 * @Date 2020/6/26 11:30
 */
@Repository
public interface ISightImgDao {

    /**
     * @Description 添加景点图片
     *
     * @param sightImg
     * @return int
     */
    @Insert("insert into tb_sight_img(sightImgId, sightId, imgPath) values(#{sightImg.sightImgId},#{sightImg.sightId},#{sightImg.imgPath})")
    int insert(@Param("sightImg") SightImg sightImg) throws SQLException;

    /**
     * @Description 通过图片id删除景点图片
     *
     * @param sightImgId
     * @return int
     */
    @Delete("delete from tb_sight_img where sightImgId=#{sightImgId}")
    int delete(String sightImgId) throws SQLException;

    /**
     * @Description 通过景点id查找景点对应的图片
     *
     * @param sightId
     * @return java.util.List<cn.hut.travel.bean.SightImg>
     */
    @Select("select * from tb_sight_img where sightId=#{sightId}")
    List<SightImg> selectBySightId(String sightId) throws SQLException;
}
